from flask import Flask, render_template

app = Flask(__name__)


@app.route('/')
@app.route('/index')
def index():
    return 'Hello World!'


@app.route('/login')
def login():
    return 'Login Success!'


# Flask 之模板的使用
# 1、直接返回html格式
@app.route('/hello')
def t_hello_world():
    user = {'username': 'chenhuayan'}
    return '''
            <html>
                <head>
                    <title>Home Page - CSDN</title>
                </head>
                <body>
                    <h1>Hello, ''' + user['username'] + '''!</h1>
                </body>
            </html>
            '''


@app.route('/tmp')
def tmp_hello_world():
    user = {'username': '这是模板生成的'}
    return render_template('index.html', title='Home', user=user)


if __name__ == '__main__':
    app.run()
